From f69a68961f4e99444bb609893baa2f7e92c9d9d3 Mon Sep 17 00:00:00 2001 From: Gianni Tedesco Date: Fri, 20 Aug 2010 17:12:00 +0100 Subject: [PATCH] xl: poison data objects in auto-generated destructors Increase the probability of blowing up badly up during any use-after-destroy scenarios. Signed-off-by: Gianni Tedesco Acked-by: Ian Campbell Signed-off-by: Ian Jackson --- tools/libxl/gentypes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py index 175fae3e3c..52cbf1f25b 100644 --- a/tools/libxl/gentypes.py +++ b/tools/libxl/gentypes.py @@ -145,15 +145,19 @@ if __name__ == '__main__': #include #include +#include #include "libxl.h" +#define LIBXL_DTOR_POISON 0xa5 + """ % " ".join(sys.argv)) for ty in [t for t in types if t.destructor_fn is not None and t.autogenerate_destructor]: f.write("void %s(%s *p)\n" % (ty.destructor_fn, ty.typename)) f.write("{\n") f.write(libxl_C_type_destroy(ty, "p", True)) + f.write("\tmemset(p, LIBXL_DTOR_POISON, sizeof(*p));\n") f.write("}\n") f.write("\n") f.close() -- 2.30.2